﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Data.SqlTypes;

namespace DataAccess.Operate
{
    public class DA_Project_Operate : SqlInteractionBase
    {
        private DataEntity.T_Project _objMessage = null;

        public override bool Insert(object obj)
        {
            SqlCommand cmdToExecute = new SqlCommand();
            cmdToExecute.CommandText = "dbo.[sp_t_Project_Insert]";
            cmdToExecute.CommandType = CommandType.StoredProcedure;

            // Use base class' connection object
            cmdToExecute.Connection = _mainConnection;

            this._objMessage = (DataEntity.T_Project)obj;

            try
            {
                cmdToExecute.Parameters.Add(new SqlParameter("@guidProject_ID", SqlDbType.UniqueIdentifier, 16, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_ID));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_NO", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_NO));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProjectNOIdx", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.ProjectNOIdx));
                cmdToExecute.Parameters.Add(new SqlParameter("@daProject_SignDate", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_SignDate));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_DepartmentID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_DepartmentID));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_Name", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Name));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_SignTypeID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_SignTypeID));
                cmdToExecute.Parameters.Add(new SqlParameter("@daProject_AgencyDateBegin", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_AgencyDateBegin));
                cmdToExecute.Parameters.Add(new SqlParameter("@daProject_AgencyDateEnd", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_AgencyDateEnd));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_Developer", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Developer));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_DeveloperProvinceID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_DeveloperProvinceID));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_DeveloperCityID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_DeveloperCityID));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_DeveloperDistrictID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_DeveloperDistrictID));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_DeveloperAddress", SqlDbType.NVarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_DeveloperAddress));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_DeveloperDistrictPropertyID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_DeveloperDistrictPropertyID));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_PresentID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_PresentID));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_AccountCycle", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_AccountCycle));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_AccountCondition", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_AccountCondition));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_DirecterCode", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_DirecterCode));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_Directer", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Directer));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_Directer1Code", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Directer1Code));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_Directer1", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Directer1));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_ManagerCode", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_ManagerCode));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_Manager", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Manager));

                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_Business", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Business));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_BusinessCode", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_BusinessCode));

                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_DepartmentHead", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_DepartmentHead));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_DepartmentHeadCode", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_DepartmentHeadCode));

                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_OutComm_FirstA1", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_OutComm_FirstA1));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_Referral_FirstA1", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Referral_FirstA1));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_AccountCondition_FirstA1", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_AccountCondition_FirstA1));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_AccountCycle_FirstA1", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_AccountCycle_FirstA1));

                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_Audit", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Audit));

                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_OutComm_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_OutComm_ID));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_Referral_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Referral_ID));

                cmdToExecute.Parameters.Add(new SqlParameter("@dcProject_AvailableArea", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, _objMessage.Project_AvailableArea));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcProject_AvailableVolume", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, _objMessage.Project_AvailableVolume));
                if (_mainConnectionIsCreatedLocal)
                {
                    // Open connection.
                    _mainConnection.Open();
                }
                else
                {
                    if (_mainConnectionProvider.IsTransactionPending)
                    {
                        cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
                    }
                }

                // Execute query.
                _rowsAffected = cmdToExecute.ExecuteNonQuery();
                return true;
            }
            catch (Exception ex)
            {
                // some error occured. Bubble it to caller and encapsulate Exception object
                throw new Exception("T_Project::Insert::Error occured.", ex);
            }
            finally
            {
                if (_mainConnectionIsCreatedLocal)
                {
                    // Close connection.
                    _mainConnection.Close();
                }
                cmdToExecute.Dispose();
            }
        }

        public override bool Delete(object obj)
        {
            SqlCommand cmdToExecute = new SqlCommand();
            cmdToExecute.CommandText = "dbo.[sp_t_Project_Delete]";
            cmdToExecute.CommandType = CommandType.StoredProcedure;

            // Use base class' connection object
            cmdToExecute.Connection = _mainConnection;

            try
            {
                cmdToExecute.Parameters.Add(new SqlParameter("@guidProject_ID", SqlDbType.UniqueIdentifier, 16, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, SqlGuid.Parse(obj.ToString())));

                if (_mainConnectionIsCreatedLocal)
                {
                    // Open connection.
                    _mainConnection.Open();
                }
                else
                {
                    if (_mainConnectionProvider.IsTransactionPending)
                    {
                        cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
                    }
                }

                // Execute query.
                _rowsAffected = cmdToExecute.ExecuteNonQuery();
                return true;
            }
            catch (Exception ex)
            {
                // some error occured. Bubble it to caller and encapsulate Exception object
                throw new Exception("T_Project::Delete::Error occured.", ex);
            }
            finally
            {
                if (_mainConnectionIsCreatedLocal)
                {
                    // Close connection.
                    _mainConnection.Close();
                }
                cmdToExecute.Dispose();
            }
        }

        public override object SelectOne(object obj)
        {
            SqlCommand cmdToExecute = new SqlCommand();
            cmdToExecute.CommandText = "dbo.[sp_t_Project_SelectOne]";
            cmdToExecute.CommandType = CommandType.StoredProcedure;
            DataTable toReturn = new DataTable("t_Project");
            SqlDataAdapter adapter = new SqlDataAdapter(cmdToExecute);

            // Use base class' connection object
            cmdToExecute.Connection = _mainConnection;

            try
            {
                this._objMessage = new DataEntity.T_Project();
                cmdToExecute.Parameters.Add(new SqlParameter("@guidProject_ID", SqlDbType.UniqueIdentifier, 16, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, SqlGuid.Parse(obj.ToString())));

                if (_mainConnectionIsCreatedLocal)
                {
                    // Open connection.
                    _mainConnection.Open();
                }
                else
                {
                    if (_mainConnectionProvider.IsTransactionPending)
                    {
                        cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
                    }
                }

                // Execute query.
                adapter.Fill(toReturn);
                if (toReturn.Rows.Count > 0)
                {
                    this._objMessage.Project_ID = (Guid)toReturn.Rows[0]["Project_ID"];
                    this._objMessage.Project_NO = (string)toReturn.Rows[0]["Project_NO"];
                    this._objMessage.Project_SignDate = (DateTime)toReturn.Rows[0]["Project_SignDate"];
                    this._objMessage.Project_DepartmentID = (Int32)toReturn.Rows[0]["Project_DepartmentID"];
                    this._objMessage.Project_Name = (string)toReturn.Rows[0]["Project_Name"];
                    this._objMessage.Project_SignTypeID = (Int32)toReturn.Rows[0]["Project_SignTypeID"];
                    this._objMessage.Project_AgencyDateBegin = (DateTime)toReturn.Rows[0]["Project_AgencyDateBegin"];
                    this._objMessage.Project_AgencyDateEnd = (DateTime)toReturn.Rows[0]["Project_AgencyDateEnd"];
                    this._objMessage.Project_Developer = (string)toReturn.Rows[0]["Project_Developer"];
                    this._objMessage.Project_DeveloperProvinceID = (Int32)toReturn.Rows[0]["Project_DeveloperProvinceID"];
                    this._objMessage.Project_DeveloperCityID = (Int32)toReturn.Rows[0]["Project_DeveloperCityID"];
                    this._objMessage.Project_DeveloperDistrictID = (Int32)toReturn.Rows[0]["Project_DeveloperDistrictID"];
                    this._objMessage.Project_DeveloperAddress = (string)toReturn.Rows[0]["Project_DeveloperAddress"];
                    this._objMessage.Project_DeveloperDistrictPropertyID = (Int32)toReturn.Rows[0]["Project_DeveloperDistrictPropertyID"];
                    this._objMessage.Project_PresentID = (Int32)toReturn.Rows[0]["Project_PresentID"];
                    this._objMessage.Project_AccountCycle = (Int32)toReturn.Rows[0]["Project_AccountCycle"];
                    this._objMessage.Project_AccountCondition = (Int32)toReturn.Rows[0]["Project_AccountCondition"];
                    this._objMessage.Project_DirecterCode = toReturn.Rows[0]["Project_DirecterCode"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Project_DirecterCode"];
                    this._objMessage.Project_Directer = toReturn.Rows[0]["Project_Directer"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Project_Directer"];
                    this._objMessage.Project_Directer1Code = toReturn.Rows[0]["Project_Directer1Code"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Project_Directer1Code"];
                    this._objMessage.Project_Directer1 = toReturn.Rows[0]["Project_Directer1"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Project_Directer1"];
                    this._objMessage.Project_ManagerCode = toReturn.Rows[0]["Project_ManagerCode"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Project_ManagerCode"];
                    this._objMessage.Project_Manager = toReturn.Rows[0]["Project_Manager"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Project_Manager"];
                    this._objMessage.Project_Audit = (Int32)toReturn.Rows[0]["Project_Audit"];
                    this._objMessage.Project_AccountCondition_FirstA1 = toReturn.Rows[0]["Project_AccountCondition_FirstA1"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Project_AccountCondition_FirstA1"]; 
                    this._objMessage.Project_AccountCycle_FirstA1 = toReturn.Rows[0]["Project_AccountCycle_FirstA1"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Project_AccountCycle_FirstA1"];
                    this._objMessage.Project_Referral_FirstA1 = toReturn.Rows[0]["Project_Referral_FirstA1"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Project_Referral_FirstA1"];
                    this._objMessage.Project_OutComm_FirstA1 = toReturn.Rows[0]["Project_OutComm_FirstA1"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Project_OutComm_FirstA1"];
                    this._objMessage.Project_OutComm_ID = (Int32)toReturn.Rows[0]["Project_OutComm_ID"];
                    this._objMessage.Project_Referral_ID = (Int32)toReturn.Rows[0]["Project_Referral_ID"];
                    this._objMessage.Project_AvailableArea = (decimal)toReturn.Rows[0]["Project_AvailableArea"];
                    this._objMessage.Project_AvailableVolume = (decimal)toReturn.Rows[0]["Project_AvailableVolume"];
                    this._objMessage.Project_Business = toReturn.Rows[0]["Project_Business"].ToString();
                    this._objMessage.Project_BusinessCode = toReturn.Rows[0]["Project_BusinessCode"].ToString();
                    this._objMessage.Project_DepartmentHead = toReturn.Rows[0]["Project_DepartmentHead"].ToString();
                    this._objMessage.Project_DepartmentHeadCode = toReturn.Rows[0]["Project_DepartmentHeadCode"].ToString();


                }
                return this._objMessage;
            }
            catch (Exception ex)
            {
                // some error occured. Bubble it to caller and encapsulate Exception object
                throw new Exception("T_Project::SelectOne::Error occured.", ex);
            }
            finally
            {
                if (_mainConnectionIsCreatedLocal)
                {
                    // Close connection.
                    _mainConnection.Close();
                }
                cmdToExecute.Dispose();
                adapter.Dispose();
            }
        }

        public override bool Update(object obj)
        {
            SqlCommand cmdToExecute = new SqlCommand();
            cmdToExecute.CommandText = "dbo.[sp_t_Project_Update]";
            cmdToExecute.CommandType = CommandType.StoredProcedure;

            // Use base class' connection object
            cmdToExecute.Connection = _mainConnection;
            this._objMessage = (DataEntity.T_Project)obj;
            try
            {
                cmdToExecute.Parameters.Add(new SqlParameter("@guidProject_ID", SqlDbType.UniqueIdentifier, 16, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_ID));
                cmdToExecute.Parameters.Add(new SqlParameter("@daProject_SignDate", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_SignDate));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_DepartmentID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_DepartmentID));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_Name", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Name));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_SignTypeID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_SignTypeID));
                cmdToExecute.Parameters.Add(new SqlParameter("@daProject_AgencyDateBegin", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_AgencyDateBegin));
                cmdToExecute.Parameters.Add(new SqlParameter("@daProject_AgencyDateEnd", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_AgencyDateEnd));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_Developer", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Developer));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_DeveloperProvinceID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_DeveloperProvinceID));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_DeveloperCityID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_DeveloperCityID));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_DeveloperDistrictID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_DeveloperDistrictID));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_DeveloperAddress", SqlDbType.NVarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_DeveloperAddress));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_DeveloperDistrictPropertyID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_DeveloperDistrictPropertyID));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_PresentID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_PresentID));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_AccountCycle", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_AccountCycle));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_AccountCondition", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_AccountCondition));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_DirecterCode", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_DirecterCode));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_Directer", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Directer));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_Directer1Code", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Directer1Code));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_Directer1", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Directer1));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_ManagerCode", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_ManagerCode));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_Manager", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Manager));


                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_Business", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Business));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_BusinessCode", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_BusinessCode));

                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_DepartmentHead", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_DepartmentHead));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_DepartmentHeadCode", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_DepartmentHeadCode));

                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_AccountCycle_FirstA1", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_AccountCycle_FirstA1));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_AccountCondition_FirstA1", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_AccountCondition_FirstA1));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_OutComm_FirstA1", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_OutComm_FirstA1));
                cmdToExecute.Parameters.Add(new SqlParameter("@sProject_Referral_FirstA1", SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Referral_FirstA1));

                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_OutComm_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_OutComm_ID));
                cmdToExecute.Parameters.Add(new SqlParameter("@iProject_Referral_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Project_Referral_ID));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcProject_AvailableVolume", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, _objMessage.Project_AvailableVolume));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcProject_AvailableArea", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, _objMessage.Project_AvailableArea));

                if (_mainConnectionIsCreatedLocal)
                {
                    // Open connection.
                    _mainConnection.Open();
                }
                else
                {
                    if (_mainConnectionProvider.IsTransactionPending)
                    {
                        cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
                    }
                }

                // Execute query.
                _rowsAffected = cmdToExecute.ExecuteNonQuery();
                return true;
            }
            catch (Exception ex)
            {
                // some error occured. Bubble it to caller and encapsulate Exception object
                throw new Exception("T_Project::Update::Error occured.", ex);
            }
            finally
            {
                if (_mainConnectionIsCreatedLocal)
                {
                    // Close connection.
                    _mainConnection.Close();
                }
                cmdToExecute.Dispose();
            }
        }
    }
}
